/*     */ package com.qmsk.business.info.scheduleType.controller;
/*     */ 
/*     */ import com.qmsk.business.info.scheduleType.dao.ScheduleTypeDAO;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/scheduleType"})
/*     */ public class ScheduletTypeController
/*     */ {
/*  28 */   private static final Logger logger = Logger.getLogger(ScheduletTypeController.class);
/*     */ 
/*     */   @Autowired
/*     */   private ScheduleTypeDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  53 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  55 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, nPageIdx, nPageSize);
/*  56 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  58 */       logger.error(e);
/*  59 */       ResponseUtils.setErrorMsgResponse(
/*  60 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId)
/*     */   {
/*     */     try
/*     */     {
/*  76 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId);
/*  77 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  79 */       logger.error(e);
/*  80 */       ResponseUtils.setErrorMsgResponse(
/*  81 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/groupCode/{shopId}/{groupCode}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getGroupCode(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("groupCode") Integer groupCode)
/*     */   {
/*     */     try
/*     */     {
/*  98 */       GsonEbRst gsonEbRst = this.dao.getGsonOfGroupCode(groupCode, shopId);
/*  99 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 101 */       logger.error(e);
/* 102 */       ResponseUtils.setErrorMsgResponse(
/* 103 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/bussBill"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void findBussBill(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId)
/*     */   {
/*     */     try {
/* 111 */       GsonEbRst gsonEbRst = this.dao.getGsonOfBussBill(shopId);
/* 112 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 114 */       logger.error(e);
/* 115 */       ResponseUtils.setErrorMsgResponse(
/* 116 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 131 */     String sGsonInData = request.getParameter("data");
/*     */     try
/*     */     {
/* 134 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/* 135 */       DbConnection.commit();
/* 136 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 137 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 138 */         response);
/*     */     } catch (Exception e) {
/* 140 */       DbConnection.rollback();
/* 141 */       logger.error(e);
/* 142 */       ResponseUtils.setErrorMsgResponse(
/* 143 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 144 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 159 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 161 */       String[] strParams = id.split(",");
/* 162 */       int nResult = this.dao.deleteParams(strParams);
/* 163 */       DbConnection.commit();
/* 164 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 165 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 166 */         response);
/*     */     } catch (Exception e) {
/* 168 */       DbConnection.rollback();
/* 169 */       logger.error(e);
/* 170 */       ResponseUtils.setErrorMsgResponse(
/* 171 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 172 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 188 */     String id = request.getParameter("id");
/* 189 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 191 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 192 */       if (g == null) {
/* 193 */         ResponseUtils.setErrorMsgResponse(
/* 194 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 195 */           response);
/*     */       } else {
/* 197 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 198 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 199 */           RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request), 
/* 200 */           response);
/*     */       }
/* 202 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 204 */       DbConnection.rollback();
/* 205 */       logger.error(e);
/* 206 */       ResponseUtils.setErrorMsgResponse(
/* 207 */         RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request) + ":" + 
/* 208 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.scheduleType.controller.ScheduletTypeController
 * JD-Core Version:    0.5.3
 */